#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int a[N], b[N], ans[N];
LL d1[N], d2[N];
vector<int>g[N];
vector<LL>mp;
int n;
void dfs(int u, int f)
{
	//cout<<"u=="<<u<<endl;
	d1[u] = d1[f] + a[u];
	d2[u] = d2[f] + b[u];
	//cout<<"d2=="<<d2[u]<<endl;
	mp.push_back(d2[u]);
	int l = -1, r = mp.size();
	while (l + 1 < r) {
		int mid = l + r >> 1;
		if (mp[mid] <= d1[u])l = mid;
		else r = mid;
	}
	ans[u] = l;
	for (auto x : g[u]) {
		dfs(x, u);
	}
	mp.pop_back();
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		scanf("%d", &n);
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(ans, 0, sizeof(ans));
		for (int i = 1; i <= n; i++) {
			g[i].clear();
		}
		for (int i = 2; i <= n; i++) {
			int x, v1, v2;
			scanf("%d%d%d", &x, &v1, &v2);
			g[x].push_back(i);
			a[i] = v1;
			b[i] = v2;
		}
		dfs(1, 0);
		for (int i = 2; i <= n; i++) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}
	return 0;
}